﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Acgmx_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            if (Request.Form["username"] != null && Request.Form["username"] != string.Empty && Request.Form["password"] != null && Request.Form["password"] != string.Empty && Request.Form["Verification"] != null && Request.Form["Verification"] != string.Empty)
            {
                if (Session["vfycode"].ToString().ToLower().Equals(Request.Form["Verification"].ToLower()))
                {
                    string acc = Request.Form["username"], pass = Request.Form["password"];
                    UserActions action = new UserActions();
                    DataTable user = action.Login(acc, DESEncrypt.Encrypt(pass));
                    if (user.Rows.Count < 1) Response.Redirect("login.aspx" + "?err=user");
                    else
                    {
                        Session["manage"] = user.Rows[0]["ID"];
                        Response.Redirect("program/news/list.aspx");
                    }
                }
                else
                    Response.Redirect("login.aspx" + "?err=code");
            }
            else
                Response.Redirect("login.aspx" + "?err=info");
        }
    }
}